//
//  DYPaymentRecordsView.m
//  kafuMerchant
//
//  Created by 帝云科技 on 2018/9/12.
//  Copyright © 2018年 帝云科技. All rights reserved.
//

#import "DYPaymentRecordsView.h"

@interface DYPaymentRecordsView ()

@property (nonatomic,strong)UILabel *titleLabel;
@property (nonatomic,strong)UIButton *startButton;
@property (nonatomic,strong)UIButton *endButton;
@property (nonatomic,strong)UILabel *aLabel;

@end

@implementation DYPaymentRecordsView

-(instancetype)initWithFrame:(CGRect)frame
{
    self=[super initWithFrame:frame];
    if (self) {
        [self initUI];
    }
    return self;
}
-(void)initUI
{
    self.backgroundColor=WhiteColor;
    
    self.titleLabel = ({
        UILabel *label=[Utils labelWithTitle:@"起止日期" titleFontSize:12 textColor:[UIColor xhq_content] backgroundColor:WhiteColor alignment:0];
        label;
    });
    
    self.startButton = ({
        
        UIButton *button=[Utils createBtnWithType:UIButtonTypeCustom backgroundColor:ClearColor action:@selector(buttonClick:) target:self title:@"开始日期" image:nil font:14 textColor:[UIColor xhq_aTitle]];
        button.contentHorizontalAlignment=UIControlContentHorizontalAlignmentLeft;
        button;
    });
    
    self.endButton = ({
        
        UIButton *button=[Utils createBtnWithType:UIButtonTypeCustom backgroundColor:ClearColor action:@selector(buttonClick:) target:self title:@"结束日期" image:nil font:14 textColor:[UIColor xhq_aTitle]];
        button.contentHorizontalAlignment=UIControlContentHorizontalAlignmentLeft;
        button;
        
    });
    
    self.aLabel = ({
        UILabel *label=[Utils labelWithTitle:@"至" titleFontSize:14 textColor:XHQHexColor(0x2A2A2A) backgroundColor:WhiteColor alignment:0];
        label;
    });
    
    self.line = ({
        UILabel *line=[UILabel xhq_lineLabel];
        line;
    });
    
    [self addSubview:self.titleLabel];
    [self addSubview:self.startButton];
    [self addSubview:self.endButton];
    [self addSubview:self.aLabel];
    [self addSubview:self.line];
    
    
    [self.titleLabel makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(BILIWIDTH(10));
        make.top.equalTo(BILIHEIGHT(17));
    }];
    
    [self.startButton makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.titleLabel);
        make.top.equalTo(self.titleLabel.bottom).offset(BILIHEIGHT(8));
        make.width.equalTo(BILIWIDTH(90));
    }];
    
    [self.aLabel makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.startButton.right).offset(BILIWIDTH(25));
        make.centerY.equalTo(self.startButton);
    }];
    
    
    [self.endButton makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.aLabel.right).offset(BILIWIDTH(35));
        make.centerY.equalTo(self.startButton);
        make.width.equalTo(BILIWIDTH(90));
    }];
    
    [self.line makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(BILIWIDTH(10));
        make.right.equalTo(BILIWIDTH(-10));
        make.bottom.equalTo(self);
        make.height.equalTo(BILIWIDTH(0.7));
    }];
    
    self.line.hidden=YES;
}
-(void)buttonClick:(UIButton *)button
{
    if (button==self.startButton) {
        !self.recordTimeBlock?:self.recordTimeBlock(0);
    }else{
         !self.recordTimeBlock?:self.recordTimeBlock(1);
    }
}

-(void)setStartTime:(NSString *)startTime
{
    _startTime=startTime;
    
    [self.startButton setTitle:startTime forState:UIControlStateNormal];
}

-(void)setEndTime:(NSString *)endTime
{
    _endTime=endTime;
    
    [self.endButton setTitle:endTime forState:UIControlStateNormal];
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end


@interface DYPaymentRecordsSecondView ()

@property (nonatomic,strong)UILabel *titleLabel1;
@property (nonatomic,strong)UILabel *titleLabel2;
@property (nonatomic,strong)UILabel *recordsLabel;
@property (nonatomic,strong)UILabel *moneyLabel;

@end


@implementation DYPaymentRecordsSecondView

-(instancetype)initWithFrame:(CGRect)frame
{
    if (self=[super initWithFrame:frame]) {
        [self initView];
    }
    return self;
}
-(void)initView
{
    self.backgroundColor=WhiteColor;
    
    self.titleLabel1 = ({
        UILabel *label=[Utils labelWithTitle:@"收款记录" titleFontSize:14 textColor:[UIColor xhq_content] backgroundColor:WhiteColor alignment:2];
        label;
    });
    
    self.titleLabel2 = ({
        UILabel *label=[Utils labelWithTitle:@"收款金额" titleFontSize:14 textColor:[UIColor xhq_content] backgroundColor:WhiteColor alignment:0];
        label;
    });
    
    self.recordsLabel = ({
        UILabel *label=[Utils labelWithTitle:@"0笔" titleFontSize:18 textColor:[UIColor xhq_base] backgroundColor:WhiteColor alignment:1];
        label;
    });
    
    self.moneyLabel = ({
        UILabel *label=[Utils labelWithTitle:@"0.00元" titleFontSize:18 textColor:[UIColor xhq_red] backgroundColor:WhiteColor alignment:1];
        label;
    });
    
    [self addSubview:self.titleLabel1];
    [self addSubview:self.titleLabel2];
    [self addSubview:self.recordsLabel];
    [self addSubview:self.moneyLabel];
    
    
    [self.titleLabel1 makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.left).offset(kScreenWidth/2-BILIWIDTH(40));
        make.top.equalTo(BILIHEIGHT(12));
    }];
    
    [self.titleLabel2 makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.titleLabel1.right).offset(BILIWIDTH(80));
        make.top.equalTo(self.titleLabel1);
    }];
    
    [self.recordsLabel makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.titleLabel1.bottom).offset(BILIHEIGHT(10));
        make.centerX.equalTo(self.titleLabel1);
    }];
    
    [self.moneyLabel makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.titleLabel2);
        make.centerY.equalTo(self.recordsLabel);
    }];
    
    
    
}

@end
